<%@ page import="java.util.*,com.release.utils.*,java.text.*,java.io.*,com.release.bean.*" %>
<%

try {
	 session = request.getSession();
  /*
  if (session.getAttribute("USER_ID") == null || !((String) session.getAttribute("SESSION_ID")).equals(session.getId())) {

	
				try {
					response.sendRedirect("LoginPage.jsp");
				} catch (IOException ioe) {
					ioe.printStackTrace();
				}


	
			}
			
		
			else
*/

	{
		Vector ReleaseReportVector = null;	
		Vector FilterVector = null;
		String usergroupname = (String)session.getAttribute("USER_GROUP_NAME"); 
		//DBUtil dbutil = new DBUtil(getServletContext());
		DBUtil dbutil = new DBUtil();
		ReleaseUtil releaseUtil = new ReleaseUtil();
		String userid = (String)session.getAttribute("USER_ID")==null?"":(String)session.getAttribute("USER_ID");
		userid= "joju.varghese@cgi.com";
		String getreport = (String)request.getParameter("getreportbutton")==null?"":request.getParameter("getreportbutton");
		String releaseName = (String)request.getParameter("releaseName")==null?(request.getParameter("hiddenrelname")==null?"":request.getParameter("hiddenrelname")):request.getParameter("releaseName");
		String filterreportbutton = (String)request.getParameter("filterreportbutton")==null?"":request.getParameter("filterreportbutton");

			System.out.println(">>>>>> filterreportbutton :"+filterreportbutton);
			filterreportbutton="Get Filter Report";

			//ReleaseReportVector =(Vector) session.getAttribute("RELEASE_FILTER_REPORT");

					String ftr_dbname = (String)request.getParameter("ftr_dbname")==null?"0":request.getParameter("ftr_dbname");
					String ftr_objtype = (String)request.getParameter("ftr_objtype")==null?"0":request.getParameter("ftr_objtype");
					String ftr_user = (String)request.getParameter("ftr_user")==null?"0":request.getParameter("ftr_user");
			if(getreport.equals("Get Report")){
					ReleaseReportVector = dbutil.getReleaseReport(releaseName);
					
					}


					if(filterreportbutton.equals("Get Filter Report") ){
					
					System.out.println(">>>>>> releaseName :"+releaseName+":"+ftr_dbname+":"+ftr_objtype+":"+ftr_user);
					//FilterVector = dbutil.getFilterReport(releaseName, ftr_dbname, ftr_objtype, ftr_user);
					ReleaseReportVector = releaseUtil.getFilterReport(releaseName, ftr_dbname, ftr_objtype, ftr_user);
					//session.removeAttribute("RELEASE_FILTER_REPORT");
					/*
					if(FilterVector!=null){
					
						session.setAttribute("RELEASE_FILTER_REPORT", FilterVector);
					
						}
						*/
					
					
					}

%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>


			function checkForRelease(obj){
			
			 if( obj.value == 0){
					alert("Kindly select Release Name from the list.");
					obj.focus();
					return false;
				 }

				 document.searchReleaseReport.action="ReleaseReport.jsp";
				 document.searchReleaseReport.filterreportbutton.value="Get Filter Report";
				 alert('checkForRelease()');
				 document.searchReleaseReport.submit();
				
			}

			function exportToExcelForCR(relName)
				{
					document.FilterReportDisplayForm.action = "ExportToExcelForCRNotes.jsp";	
					document.FilterReportDisplayForm.submit();
					document.FilterReportDisplayForm.action = "ReleaseReport.jsp";
			 	}
				
			function submitThisForReport()
				{
					document.searchReleaseReport.releaseName.value = document.FilterReportDisplayForm.hiddenrelname.value
					document.searchReleaseReport.filterreportbutton.value = "Get Filter Report";
					document.searchReleaseReport.submit();
					document.FilterReportDisplayForm.submit();
				}

			function exportToExcelForFilter()
				{
					document.FilterReportDisplayForm.action = "ExportToExcelForFilter.jsp";	
					document.FilterReportDisplayForm.submit();
					document.FilterReportDisplayForm.action = "ReleaseReport.jsp";
				}
			function exportToExcelForDBA()
				{
					document.ReleaseDBAReportDisplay.action = "ExportToExcelForDBA.jsp";	
					document.ReleaseDBAReportDisplay.submit();
					document.ReleaseDBAReportDisplay.action = "ReleaseReport.jsp";
				}	


			function trim(sString)
				  {
					sTrimmedString = "";
				    if (sString != "") {
					  var iStart = 0;
					  var iEnd = sString.length - 1;
					  // var sWhitespace = " \t\f\n\r\v";
					  var sWhitespace = "   ";
		
		
					  while (sWhitespace.indexOf(sString.charAt(iStart)) != -1) {
						 iStart++;
						 if (iStart > iEnd) 
							break;
					  }

					  // If the string not just whitespace
					  if (iStart <= iEnd) {
						 while (sWhitespace.indexOf(sString.charAt(iEnd)) != -1)
							iEnd--;
							 sTrimmedString = sString.substring(iStart,++iEnd);
						  }
					   }
				   return sTrimmedString;
				 }

		  function checkforempty()
			{
			
				document.ReleaseExecuteForm.unixServerForRel.value =trim(document.ReleaseExecuteForm.unixServerForRel.value);
				document.ReleaseExecuteForm.unixServerUserid.value =trim(document.ReleaseExecuteForm.unixServerUserid.value);
				document.ReleaseExecuteForm.unixServerPwd.value =trim(document.ReleaseExecuteForm.unixServerPwd.value);
			
			
				if(submitForms(document.ReleaseExecuteForm.unixServerForRel, document.ReleaseExecuteForm.unixServerUserid, document.ReleaseExecuteForm.unixServerPwd))
				{
					document.ReleaseExecuteForm.Act.value = "Execute Shell for Release";
					document.ReleaseExecuteForm.submit();
				}
				
			}


			function checkforempty2()
			{
			
				document.ReleaseExecuteForm.unixServerForRel.value =trim(document.ReleaseExecuteForm.unixServerForRel.value);
				document.ReleaseExecuteForm.unixServerUserid.value =trim(document.ReleaseExecuteForm.unixServerUserid.value);
				document.ReleaseExecuteForm.unixServerPwd.value =trim(document.ReleaseExecuteForm.unixServerPwd.value);
			
			
				if(submitForms(document.ReleaseExecuteForm.unixServerForRel, document.ReleaseExecuteForm.unixServerUserid, document.ReleaseExecuteForm.unixServerPwd))
				{
					document.ReleaseExecuteForm.Act.value = "Get Log for Release";
					document.ReleaseExecuteForm.submit();
				}
				
			}


			function submitForms(obj1, obj2, obj3){
	
			    if (obj1.value.length == 0 ){
					alert("Please enter unix server name.");
					obj1.focus();
					return false;
				 }

				 if( obj2.value.length == 0){
					alert("Please enter unix server userid.");
					obj2.focus();
					return false;
				 }

				 if( obj3.value.length == 0){
					alert("Please enter unix server password.");
					obj3.focus();
					return false;
				}
			
				return true;
				//  document.updateRelease.submit();
				//  document.searchReleaseForm.submit();
	
				//document.displayForm.submit();
		  	
		  				//  document.MainForm.submit();
						//alert("HIIIIIII");
			}
		
		function overviewCRDetails(ReleaseObjKey) {
			dwin=window.open("OverviewCRDetail.jsp?relobjkey="+ReleaseObjKey,"detailWin","width=900,height=600,scrollbars=yes,resizable=yes");
			dwin.focus();
		
		}
		</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Sql Script</title>
<style type="text/css">
<!--
body {
	background-image: url(../images/bg/pagebg.gif);
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style2 {font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<link href="joju.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style4 {color: #FFFFFF}
-->
</style>
</head>


<body onload="MM_preloadImages('../images/menu2_01.jpg','../images/menu2_02.jpg','../images/menu2_03.jpg','../images/menu2_04.jpg','../images/menu2_05.jpg','../images/menu2_06.jpg','../images/menu2_07.jpg ','../images/menu2_08.jpg')">
<form name="searchReleaseReport" method="post" >
<center>
  <table id="Table_01" width="1002" height="778" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td height="101" align="left" valign="top"><img src="../images/index_01.jpg" width="1002" height="101" alt="" /></td>
    </tr>
	<tr>
      <td height="46" align="left" valign="top"><table id="Table_3" width="1002" height="46" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td><a href="newtree.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image22','','../images/menu2_01.jpg',1)"><img src="../images/menu_01.jpg" alt="home" name="Image22" width="82" height="46" border="0" id="Image22" /></a></td>
            <td><a href="Data.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image23','','../images/menu2_02.jpg',1)"><img src="../images/menu_02.jpg" alt="tracker" name="Image23" width="83" height="46" border="0" id="Image23" /></a></td>
            <td><a href="ReleaseReport.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image24','','../images/menu2_03.jpg',1)"><img src="../images/menu_03.jpg" alt="documents" name="Image24" width="83" height="46" border="0" id="Image24" /></a></td>
            <td><a href="ReleaseReport.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image27','','../images/menu2_06.jpg',1)"><img src="../images/menu_06.jpg" alt="File Release" name="Image27" width="83" height="46" border="0" id="Image27" /></a></td>   
			<td><a href="ReleaseLog.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image28','','../images/menu2_07.jpg ',1)"><img src="../images/menu_07.jpg" alt="wiki" name="Image28" width="83" height="46" border="0" id="Image28" /></a></td>
            <td><a href="buldandtest.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image29','','../images/menu2_08.jpg',1)"><img src="../images/menu_08.jpg" alt="build and test" name="Image29" width="84" height="46" border="0" id="Image29" /></a></td>
            <td><img src="../images/menu_09.jpg" width="333" height="46" alt="" /></td>
            <td><img src="../images/menu_10.jpg" width="5" height="46" alt="" /></td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td height="631" align="left" valign="top"><table id="Table_" width="1002" height="595" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="2" bgcolor="#A1C0DF"><img src="../images/content_01.jpg" width="226" height="1" alt="" /></td>
            <td><img src="../images/content_02.jpg" width="776" height="1" alt="" /></td>
          </tr>
          <tr>
            <td height="574" valign="top" bgcolor="#A1C0DF">&nbsp;</td>
            <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="835" colspan="5" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="3%">&nbsp;</td>
                      <td width="97%">&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td><table id="Table_2" width="736" height="251" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="11"><img src="../images/login_01.jpg" width="11" height="11" alt="" /></td>
                          <td width="713" background="../images/login_02.jpg"><img src="../images/login_02.jpg" width="384" height="11" alt="" /></td>
                          <td width="12"><img src="../images/login_03.jpg" width="12" height="11" alt="" /></td>
                        </tr>
                        <tr>
                          <td background="../images/login_02.jpg"><img src="../images/login_04.jpg" width="11" height="224" alt="" /></td>
                          <td align="left" valign="top" background="../images/bg/loginbg.jpg">
						<input type=hidden name=hiddenrelname value='<%=releaseName%>'>
						<table cellspacing="0" cellpadding="0" width="95%" 
                          border="0">
                            <tbody>
                              <tr class="style2">
                                <td class="marginscontact"><span class="contentbold1">Release Object- Basic Details<br />
                                  <br />
                                </span></td>
                                <td class="marginscontact">&nbsp;</td>
                                <td class="marginscontact">&nbsp;</td>
                              </tr>
                              <tr class="style2">
                                <td class="marginscontact" width="44%"><div align="right"><span class="normalcontent"><span class="content">Release Name</span> <span 
                              class="photo_name">:</span></span></div></td>
                                <td class="marginscontact" width="3%">&nbsp;</td>
                                <td class="marginscontact" width="53%">
								
								<select name=releaseName  >
								
													
								<% 															
									Vector relNameVector = dbutil.getReleaseName(userid);
									for(int i=0;i<relNameVector.size();i++)
									{
										ReleaseVO relbean =(ReleaseVO)relNameVector.elementAt(i); 
								%>
	
										<option value= '<%=	relbean.getReleaseName()%>'> 									
										<%= relbean.getReleaseName()%> 
										</option>
					
								<%	}
								%>
								</select>
								
								</td>
                              </tr>
                              <tr class="style2">
                                <td class="marginscontact"><div align="right"><span class="content">Object's DB Name</span> <span 
                              class="mandatory">:</span></div></td>
                                <td class="marginscontact">&nbsp;</td>
                                <td class="marginscontact">
								
									<select name=ftr_dbname >
							<% 
								Vector dbVector = dbutil.getDbNameVO();
								for(int i=0;i<dbVector.size();i++)
								{
									DbNameVo dbvo =(DbNameVo)dbVector.elementAt(i); 
							%>

									<option value= '<%=	dbvo.getDBName()%>'  
									>
										<%= dbvo.getDBName()%> 
									</option>
				
							<%	}
							%>
							</select>
							&nbsp&nbsp
							<img id="help1" src="../images/help.jpg" border="0" width="12" height="15" onMouseover="javascript:showFiles('SelectViewHelp1');" onMouseout="javascript:hideFiles('SelectViewHelp1');">
					        <div id="SelectViewHelp1" style="position:absolute; left:event.x; top:event.y; visibility: hidden; BORDER:#666666 1px solid;background-color: #efefef;width:300px;padding:5px;" onMouseover="javascript:showFiles('SelectViewHelp1');" onMouseout="javascript:hideFiles('SelectViewHelp1');">
							        <br>Use has to select the Database name from the list. Select the database in which Object belongs. Ex if sproc belongs to 'intra' database then select intra here. Ex. if alter statement going to modify table of 'archive' database then select archive here.
					        </div>
								
								</td>
                              </tr>
                              <tr class="style2">
                                <td class="marginscontact"><div align="right"><span class="content">Object's Type</span>:</div></td>
                                <td class="marginscontact">&nbsp;</td>
                                <td class="marginscontact">
								
								<select name="ftr_objtype" id="ftr_objtype"  >
										<option value='0' >Select Object Type</option>
										<% 
											Vector objType = dbutil.getObjTypeVO();
											
											if(objType!=null && objType.size()>0){
											for(int i=0;i<objType.size();i++)
											{
												ObjectTypeVO objvo =(ObjectTypeVO)objType.elementAt(i); 
										%>

												<option value= '<%= objvo.getObjType()%>' 	> 
													<%= objvo.getObjType()%> </option>
							
										<%	} }
										%>
							</select>
								
								
								</td>
                              </tr>
                              <tr>
                                <td valign="top" class="content"><div align="right">User Updated :</div></td>
                                <td valign="top" class="marginscontact">&nbsp;</td>
                                <td class="marginscontact" valign="center">
									<input type="text" class="box" name="ftr_user" id ="ftr_user" size="31" value='<%=userid%>'> 
							  </td>
                              </tr>
         
                              <tr>
                                <td valign="top" class="content">&nbsp;</td>
                                <td valign="top" class="marginscontact">&nbsp;</td>
                                <td class="marginscontact" valign="center">
								<input type=button class=whitebutton id ="filterreportbutton" name="filterreportbutton" value="Get Filter Report" onclick="return checkForRelease(releaseName)">
								
								</td>
                              </tr>
                            </tbody>
                          </table></td>
                          <td background="../images/login_06.jpg"><img src="../images/login_06.jpg" width="12" height="224" alt="" /></td>
                        </tr>
                        <tr>
                          <td><img src="../images/login_07.jpg" width="11" height="16" alt="" /></td>
                          <td background="../images/login_08.jpg" bgcolor="#F3F7FA"><img src="../images/login_08.jpg" width="384" height="16" alt="" /></td>
                          <td><img src="../images/login_09.jpg" width="12" height="16" alt="" /></td>
                        </tr>
                      </table></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>
					
					<table cellpadding="0" cellspacing="1" width="100%" style="BORDER:#000000 1px solid" colspan=8>
										<input type=hidden name=hiddenrelname value='<%=releaseName%>'>
										<input type=hidden name=filterAction value="FilterAction">
								
										<tr bgcolor="#ADDFFF" >
												<td class=smallfonthead colspan=1 width="3%">
													<b>
														#
													</b>
												</td>
												<td class=smallfonthead colspan=1 width="10%">
													<b>
														Database Name
													</b>
												</td>
												<td class=smallfonthead colspan=1 width="10%">
													<b>
														Object Type
													</b>
												</td>
												<td class=smallfonthead colspan=1 width="15%">
													<b>
														User Updated
													</b>
												</td>
												<td class=smallfonthead colspan=1 width="30%">
													<b>
														Object Name / SQL Query
													</b>
												</td>
												<td class=smallfonthead colspan=1 width="15%">
													<b>
														Contact Person
													</b>
												</td>
												<td class=smallfonthead colspan=1 width="12%" nowrap="nowrap">
													<b>
														Date Updated
													</b>
												</td>
												<td class=smallfonthead colspan=1 width="5%">
													<b>
														CR Status
													</b>
												</td>
										</tr>	

										 <%
										 String objectnamedisplay = "";
										 String prevobjname = "";
										 int srno = 0;
										 String baccolor="";
										 if(ReleaseReportVector != null && ReleaseReportVector.size()>0){
										 for (int i=0;i<ReleaseReportVector.size();i++){	
											 ReleaseVO relvo = (ReleaseVO)ReleaseReportVector.elementAt(i);
											 if(i%2==0){
													baccolor="#C2D6EB";
													}
												else{ 
													baccolor="#EFEFEF";
													}
											 %>
											<tr bgcolor='<%=baccolor %>'>		
												<td bgcolor='<%=baccolor %>' colspan=1 align="center" width="3%" height="18">
													
														<%=++srno%>
													
												</td>
												<td bgcolor='<%=baccolor %>' colspan=1 align="center" width="10%">
													
														<%=relvo.getDBName()%>
													
												</td>
												<td bgcolor='<%=baccolor %>' colspan=1 align="left" width="10%">
													
														<%=relvo.getObjType()%>
													
												</td>
												<td bgcolor='<%=baccolor %>' colspan=1 align="left" width="15%">
													
														<%=relvo.getUserUpdated()%>
													
												</td>
												<% if(relvo.getValid().equals("N/A")){ %>
												<td bgcolor='<%=baccolor %>' colspan=1 align="left" width="30%">
													
														<%=relvo.getObjName()%>
													
												</td>
												<%} else {%>
												<td bgcolor='<%=baccolor %>' colspan=1 align="left" width="30%">

												<a href="javascript:overviewCRDetails('<%=relvo.getReleaseObjKey()%>')"><%=relvo.getObjName()%></a>

												<%}%>
												<td bgcolor='<%=baccolor %>' colspan=1 align="left" width="15%">
													
														<%=relvo.getContactPerson()==null?"":relvo.getContactPerson()%>
													
												</td>
												<td bgcolor='<%=baccolor %>' colspan=1 align="center" width="12%" nowrap="nowrap">
													
														<%=relvo.getDateUpdated()%>
													
												</td>
												<td bgcolor='<%=baccolor %>' colspan=1 align="center" width="5%">
													
														<%=relvo.getValid()%>
													
												</td>

										</tr>
									<%			
										}}else{ %>	
											<tr  >
												<td class=smallfonthead colspan=8 width="100%">
												<font  color="#FF6600">Not any objects available for selected filter criteria.</font>
												</td>
											</tr>	
										<%}%>
														
			</table>


		
					  </td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td></td>
                    </tr>
                  </table>

                    <br />
                      <br />
                      <br />
                    <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br />
                      <br /></td>
                </tr>
                
            </table></td>
          </tr>
          <tr>
            <td height="19" colspan="2" valign="top" bgcolor="#CCCCCC"><span class="contentwhitesatheesh">&copy;2010 Joju's Software. All rights reserved.</span></td>
          </tr>
      </table></td>
    </tr>
  </table>
</center>
</form>
</body>
</html>
<% 
}
}
catch(Exception e) {
				e.printStackTrace();
		}

		%>